package antoine.ear.keyboard;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Iterator;

public class KeyboardGraphic {
	
	private Graphics2D g2d;

	public KeyboardGraphic(Graphics2D g2d) {
		this.g2d = g2d;
	}
	
	public void drawKeyboard(Keyboard kb){
		Iterator ite = kb.getNotes().values().iterator();
		while (ite.hasNext()){
			Note note = (Note) ite.next();
			drawNote(note);
		}
	}
	
	public void drawNote(Note note){
		
		if (note.isActive()){
			g2d.setColor(Color.GREEN);
			g2d.draw(note);
			g2d.fill(note);
		}
		else if (note.isBlack()){
			g2d.setColor(Color.BLACK);
			g2d.draw(note);
			g2d.fill(note);
		}
		else{
			g2d.setColor(Color.BLACK);
			g2d.draw(note);
			g2d.setColor(Color.WHITE);
			g2d.fill(note);
		}
	}

}
